Multiple Sources for an Application

Beta Feature

Specifying multiple sources for an application is a beta feature. This feature is subject to change in backwards incompatible ways until it is marked stable.

By default an Argo CD application is a link between a single source and a cluster. Sometimes however, you want to combine files from multiple locations to form a single Application.

Argo CD has the ability to specify multiple sources for a single Application. Argo CD compiles all the sources and reconciles the combined resources.

You can provide multiple sources using the sources field. When you specify the sources field, Argo CD will ignore the source (singular) field.

See the below example for specifying multiple sources:

  1. apiVersion: argoproj.io/v1alpha1
  2. kind: Application
  3. metadata:
  4. name: my-billing-app
  5. namespace: argocd
  6. spec:
  7. project: default
  8. destination:
  9. server: https://kubernetes.default.svc
  10. namespace: default
  11. sources:
  12. - repoURL: https://github.com/mycompany/billing-app.git
  13. path: manifests
  14. targetRevision: 8.5.1
  15. - repoURL: https://github.com/mycompany/common-settings.git
  16. path: configmaps-billing
  17. targetRevision: HEAD

The above example has two sources specified that need to be combined in order to create the “billing” application. Argo CD will generate the manifests for each source separately and combine the resulting manifests.

Do not abuse multiple sources

Note this feature is NOT destined as a generic way to group different/unrelated applications. Take a look at applicationsets and the app-of-apps pattern if you want to have a single entity for multiple applications. If you find yourself using more than 2-3 items in the sources array then you are almost certainly abusing this feature and you need to rethink your application grouping strategy.

If multiple sources produce the same resource (same group, kind, name, and namespace), the last source to produce the resource will take precedence. Argo CD will produce a RepeatedResourceWarning in this case, but it will sync the resources. This provides a convenient way to override a resource from a chart with a resource from a Git repo.

Helm value files from external Git repository

One of the most common scenarios for using multiple sources is the following

  1. Your organization wants to use an external/public Helm chart
  2. You want to override the Helm values with your own local values
  3. You don’t want to clone the Helm chart locally as well because that would lead to duplication and you would need to monitor it manually for upstream changes.

In this scenario you can use the multiple sources features to combine the external chart with your own local values.

Helm sources can reference value files from git sources. This allows you to use a third-party Helm chart with custom, git-hosted values.

  1. apiVersion: argoproj.io/v1alpha1
  2. kind: Application
  3. spec:
  4. sources:
  5. - repoURL: 'https://prometheus-community.github.io/helm-charts'
  6. chart: prometheus
  7. targetRevision: 15.7.1
  8. helm:
  9. valueFiles:
  10. - $values/charts/prometheus/values.yaml
  11. - repoURL: 'https://git.example.com/org/value-files.git'
  12. targetRevision: dev
  13. ref: values

In the above example, the prometheus chart will use the value file from git.example.gom/org/value-files.git. $values resolves to the root of the value-files repository. The $values variable may only be specified at the beginning of the value file path.

If the path field is set in the $values source, Argo CD will attempt to generate resources from the git repository at that URL. If the path field is not set, Argo CD will use the repository solely as a source of value files.

Note

Sources with the ref field set must not also specify the chart field. Argo CD does not currently support using
another Helm chart as a source for value files.

Note

Even when the ref field is configured with the path field, $value still represents the root of sources with the ref field. Consequently, valueFiles must be specified as relative paths from the root of sources.